
package org.vasil.jouikov.schema

class Item {

    def sku, action, error
    def keywords, weight, stockdate
    def vendor = [:], etilize = [:], name = [:], preference = [:], advert = [:], banner = [:], images = [:], coupon = [:]
    def reseller = [:], price = [:], quantity = [:], manufact = [:], packages = [:], warranty = [:], google = [:]
    def node = [:], nodes = [:]

    def getItemFields = {

        def maps = [
            'vendor'    : vendor,
            'etilize'   : etilize,
            'name'      : name,
            'keywords'  : keywords,
            'preference': preference,
            'advert'    : advert,
            'banner'    : banner,
            'images'    : images,
            'coupon'    : coupon,
            'reseller'  : reseller,
            'price'     : price,
            'quantity'  : quantity,
            'manufact'  : manufact,
            'packages'  : packages,
            'warranty'  : warranty,
            'google'    : google,
            'updated'   : new Date(),
            'weight'    : weight,
            'stockdate' : stockdate,
            'active'    : 'Y'
        ]
    }

    // Time excecution
    def benchmark = { closure ->
        def start = System.currentTimeMillis()
        closure.call()
        return System.currentTimeMillis() - start
    }

    String toString() {
        return "sku=$sku, action=$action ${action == 'error' ? error : ''}"
    }
}
